<!doctype html>
<title>Blob Perf Runner</title>
<script src="resources/blob-shared.js"></script>
<script src="resources/shared.js"></script>
<body></body>
<script>
  async function start(testParams) {
    logToDocumentBody(`Starting benchmark: ${testParams.numBlobs} blobs of ` +
                      `size ${testParams.size}`);
    let start = Date.now();
    let numReadImmediately = testParams.numBlobs / 2;
    let numReadParallel = testParams.numBlobs / 2;
    logToDocumentBody('Creating blobs and reading immediately, synchronously.');
    await createBlobAndImmediatelyRead(numReadImmediately, testParams.size);
    logToDocumentBody('Creating blobs and reading immediately, asynchronously.');
    await createBlobsAndReadInParallel(numReadParallel, testParams.size);
    logToDocumentBody('Time: ' + (Date.now() - start));
    reportDone();
  }

  function getParams() {
    let testParams = {
      size: Number(document.getElementById('blob_size').value),
      numBlobs: Number(document.getElementById('num_blobs').value)
    };
    start(testParams);
  }

  if (typeof params !== 'undefined')
    start(params);
  else
    showManualInput();
</script>
